<template>
	<view class="bg">
		<uv-navbar :title="title" bg-color="rgba(0,0,0,.0)" :placeholder='true' leftIconSize="20px"
			leftIconColor="#313C56" :autoBack='true' titleStyle="font-size: 16px;font-weight: 500;color: #313c56;">
			<template v-if="type != 0" v-slot:right>
				<view class="font-14 font-weight-regular" style="color: #313C56;" @click="edit">编辑</view>
			</template>
		</uv-navbar>
		<scroll-view :scroll-y="true" style="width: 100vw; margin-top: 10px;"
			:style="{ height: $uv.addUnit(scrollHeight) }">
			<view class="font-18 font-weight-medium flex-row" style="color: #313C56; margin-left: 20px;">
				{{ detail.name }}
				<view style="margin-left: 4px;">
					<image :src="`/static/user/b${detail.bossLevel}.png`"
						style="margin-left: 6px; width: 53px; min-width: 53px; max-width: 53px;" mode="widthFix">
					</image>
				</view>
			</view>
			<view class="font-18 font-weight-medium" style="color: #313C56; margin-top: 8px; margin-left: 20px;">
				{{ detail.evaluateRatio }} %
				<text style="color: #6B7885;" class="font-12 font-weight-regular">好评率</text>
			</view>
			<view class="font-18 font-weight-medium" style="color: #313C56; margin-top: 8px; margin-left: 20px;">
				{{ detail.serviceNum }}
				<text style="color: #6B7885;" class="font-12 font-weight-regular">服务总数</text>
			</view>

			<view class="" style="margin: 12px; padding: 16px; border-radius: 12px; background-color: white;">
				<view class="flex-row flex-items-center">
					<view style="background-color: #EB7520; border-radius: 2px; height: 12px; width: 3px;"></view>
					<text class="font-16 font-weight-medium"
						style="color: #333333; margin-left: 10px;">{{detail.type == 1 ? '公司' : '团队'}}介绍</text>
				</view>
				<text class="font-14 font-weight-regular" style="color: #4F4F4F; margin-top: 8px;">
					{{ detail.intro }}
				</text>
				<view class="flex-row flex-items-center" style="margin-top: 15px;">
					<view style="background-color: #EB7520; border-radius: 2px; height: 12px; width: 3px;"></view>
					<text class="font-16 font-weight-medium" style="color: #333333; margin-left: 10px;">图片</text>
				</view>
				<view class="flex-row flex-wrap" style="">
					<image v-for="(item,index) in detail.introPics" :key="index"
						style="margin-top: 8px; border-radius: 6px; height: 80px; width: 80px; margin-right: 12px;"
						:src="item" @click="previewImage(index)">
					</image>
				</view>
				<view class="flex-row flex-items-center" style="margin-top: 15px;">
					<view style="background-color: #EB7520; border-radius: 2px; height: 12px; width: 3px;"></view>
					<text class="font-16 font-weight-medium"
						style="color: #333333; margin-left: 10px;">{{detail.type == 1 ? '公司' : '团队'}}成员
						{{detail.memberNum}} 人</text>
				</view>
				<view class="flex-row flex-wrap" style="">
					<view v-for="(item,index) in detail.members" :key="index" class="flex-column-center" style="width: 74px; height: 74px;
					border-radius: 8px; background-color: #F7F9FD; margin-right: 8px; margin-top: 8px;"
						@click="memberDetails(item.userId)">
						<image :src="item.headUrl" style="width: 32px; height: 32px; border-radius: 16px;"></image>
						<text class="font-14 font-weight-regular"
							style="color: #313C56; margin: 3px;">{{ item.nickname }}</text>
					</view>
				</view>
				<!--				<view v-if="type != 0" class="flex-row flex-end" style="margin-top: 24px;">-->
				<!--					<view class="company-btn flex-row flex-items-center">-->
				<!--						设置管理员-->
				<!--					</view>-->
				<!--					<view class="company-btn flex-row flex-items-center">-->
				<!--						邀请-->
				<!--					</view>-->
				<!--					<view class="company-btn flex-row flex-items-center">-->
				<!--						移除-->
				<!--					</view>-->
				<!--				</view>-->
			</view>

		</scroll-view>
		<!-- <view class="person-detail_toolbar" :style="{height: $uv.addUnit(toolbarHeight)}">
			<view class="person-detail_toolbar__btn flex-row-center">
				邀请任务
			</view>
		</view> -->
		<toast ref="toast"></toast>
	</view>
</template>

<script>
	import {
		getTeam
	} from "../../api";
	export default {
		data() {
			return {
				detail: {},
				type: 0,
				title: '详情',
				id: '',
			};
		},
		computed: {
			statusBarHeight() {
				const sys = uni.$uv.sys()
				return sys.statusBarHeight
			},
			navbarHeight() {
				return this.statusBarHeight + 44
			},
			screenWidth() {
				const sys = uni.$uv.sys()
				return sys.windowWidth
			},
			pageHeight() {
				const sys = uni.$uv.sys()
				return sys.windowHeight - this.navbarHeight
			},
			scrollHeight() {
				return this.pageHeight - 15
			},
			toolbarHeight() {
				const sys = uni.$uv.sys()
				return sys.safeAreaInsets.bottom + 68
			}
		},
		onLoad(parm) {
			console.error("id = " + parm.id + ", sys = " + parm.sys)
			this.id = parm.id
			this.getTeam(parm.id)
			this.type = parm.sys

		},
		methods: {
			previewImage(index) {
				uni.previewImage({
					current: index,
					urls: this.detail.introPics
				})
			},
			edit() {
				if (!this.detail.type) {
					return
				}
				if (this.detail.type == 1) {
					uni.navigateTo({
						url: '/pages/creat-company/creat-company?id=' + this.detail.id,
						events: {
							update: () => {
								this.getTeam(this.id)
							}
						}
					})
				} else {
					uni.navigateTo({
						url: '/pages/creat-team/creat-team?id=' + this.detail.id,
						events: {
							update: () => {
								this.getTeam(this.id)
							}
						}
					})
				}
			},
			/**
			 * 详情跳转
			 */
			memberDetails(id) {
				uni.navigateTo({
					url: '/pages/person-detail/person-detail?userId=' + id + "&type=0"
				})
			},

			getTeam(id) {
				let params = {
					id: id
				}
				getTeam(params).then((data) => {
					let detail = data

					this.detail = data
					this.title = data.type == 1 ? '公司详情' : '团队详情'
					console.log(this.detail)
				}).catch((e) => {})
			},
		}
	}
</script>

<style lang="scss">
	.company-btn {
		margin-left: 8px;
		height: 36px;
		padding-left: 14px;
		padding-right: 14px;
		background: #FFFFFF;
		box-shadow: 0px 1px 2px 0px rgba(16, 24, 40, 0.05);
		border-radius: 18px;
		border: 1px solid #D0D5DD;

		font-size: 14px;
		font-weight: 500;
		color: #344054;
	}

	.bg {
		background-image: url('../../static/companyBG.png');
		background-repeat: no-repeat;
		background-size: 100%;
	}

	page {
		// background-color: white;
	}

	.person-detail_toolbar__btn {
		height: 44px;
		margin-left: 36px;
		margin-right: 36px;
		margin-top: 12px;
		background-color: #EB7520;
		border-radius: 22px;
		color: white;
		font-size: 16px;
		font-weight: 400;
	}

	.person-detail_toolbar {
		position: absolute;
		left: 0px;
		bottom: 0px;
		width: 100vw;
		background-color: white;
		font-size: 16px;
		font-weight: 400;
		border-top-color: #F3F5FB;
		border-top-width: 1px;
		border-top-style: solid;
	}

	.person-detail_experience {
		margin-top: 8px;
		border-radius: 12px;
		background-color: #F7F9FD;
		padding: 12px 16px;
		width: calc(100% - 32px);
		display: flex;
		flex-direction: column;
	}

	.person-detail_label {
		background-color: #FDEFE9;
		height: 18px;
		border-radius: 9px;
		padding-left: 8px;
		padding-right: 8px;
		display: flex;
		align-items: center;
		color: #EB7520;
		font-weight: 400;
		font-size: 12px;
		margin-right: 8px;
		margin-bottom: 4px;
	}
</style>